<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('凭证体列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
								 凭证类型：<select name="params[pzzt]" >
									<option value="">全部</option>
									<option value="0">记账</option>
								</select>
							</li>
                            <li>
								<label>核算年度：</label>
								<select name="nd" id="nd">
									<option th:each="nd : ${ndlist}" th:text="${nd}" th:value="${nd}"> th:selected="${nd==year}"> </option>
								</select>
							</li>
                            <li >
								<label>核算期间： </label><select name="yf" id="yf">
								    <option th:each="yf : ${yflist}" th:text="${yf}" th:value="${yf}" th:selected="${yf==term}"></option>
								</select>
							</li>
                            <li>
                                <label style="width:80px">起凭证编号：</label>
                                <input type="text" name="params[spzbh]"/>
                            </li>
                            <li>
                                <label style="width:80px">止凭证编号：</label>
                                <input type="text" name="params[epzbh]"/>
                            </li>
                            <li>
								 科目类型：<select name="params[kmlx]" >
									<option value="1">总账科目</option>
									<option value="0">明细科目</option>
								</select>
							</li>
							<li>
                                <label>未记账：</label>
                                <input type="checkbox" name="params[sfjz]" />
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:pzhz:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table">
                  <table>
		  			<tr><td>核算期间:</td></tr>
		  			<tr><td>凭证范围:</td></tr>
		  		  </table>
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript"> 
        var prefix = ctx + "system/pzhz";

        $(function() {
            var options = {
                url: prefix + "/list", 
                exportUrl: prefix + "/export",
                modalName: "凭证汇总",
                showFooter: true,
                columns: [{
                    checkbox: true
                },
                {
                    field: 'kmdm',
                    title: '科目代码'
                },{
                    field: 'kmmc',
                    title: '科目名称'
                },
                {
                    field: 'jfje',
                    title: '借方金额',
   				    footerFormatter:function (value) {
   				    	var sumJe = 0;
   				        for (var i in value) {
   				        	sumJe += parseFloat(value[i].jfje);
   				        }
   				        return "总金额：" + number_format(sumJe,2);
   				    }
                },
                {
                    field: 'dfje',
                    title: '贷方金额',
   				    footerFormatter:function (value) {
   				    	var sumJe = 0;
   				        for (var i in value) {
   				        	sumJe += parseFloat(value[i].dfje);
   				        }
   				        return "总金额：" + number_format(sumJe,2);
   				    }
                }]
            };
            $.table.init(options);
        });
        
        
        function number_format(number, decimals, dec_point, thousands_sep) {
			　　/*
			　　 * 参数说明：
			　　 * number：要格式化的数字
			　　 * decimals：保留几位小数
			　　 * dec_point：小数点符号
			　　 * thousands_sep：千分位符号
			　　 * */
			　　 number = (number + '').replace(/[^0-9+-Ee.]/g, '');
			　　 var n = !isFinite(+number) ? 0 : +number,
			　　 prec = !isFinite(+decimals) ? 2 : Math.abs(decimals),
			 　　sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,
			 　　dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
			 　　s = '',
			　　 toFixedFix = function(n, prec) {
			 　　　　var k = Math.pow(10, prec);
			 　　　　return '' + Math.ceil(n * k) / k;
			 　　};

			 　　s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
			　　 var re = /(-?\d+)(\d{3})/;
			　　 while(re.test(s[0])) {
			 　　　　s[0] = s[0].replace(re, "$1" + sep + "$2");
			 　　}

			 　　if((s[1] || '').length < prec) {
			    　　 s[1] = s[1] || '';
			     　　s[1] += new Array(prec - s[1].length + 1).join('0');
			 　　}
			  　　　　return s.join(dec);
			 }
    </script>
</body>
</html>